from dataclasses import dataclass, field
from typing import List, Set, Dict, Optional


@dataclass
class AlbumInfo:
    name: str
    original_name: str
    order: int
    episode_count: Optional[int]
    path: str
    media_type: str = "audio"
    media_types: Set[str] = field(default_factory=set)
    media: List = field(default_factory=list)


@dataclass
class MediaInfo:
    title: str
    sequence: int
    media_type: str
    file_format: str
    file_path: str
    local_path: str
    sort_idx: int
    album_name: Optional[str] = None
    file_size: Optional[int] = None
    duration:Optional[float] = None
    is_uploaded: bool = False


@dataclass
class UploadTask:
    album_name: str
    local_path: str
    remote_key: str
    file_path: str
    album_order: int
    media_order: int
    media_type: str
    file_size: Optional[int] = None
    duration: Optional[float] = None
    is_uploaded: bool = False
    error: Optional[str] = None


@dataclass
class ScanResult:
    category_name: str
    category_media_type: str = "mixed"
    album_order_map: Dict[str, int] = field(default_factory=dict)
    album_id_map: Dict[str, AlbumInfo] = field(default_factory=dict)
    total_albums: int = 0
    total_media: int = 0
    upload_tasks: List[UploadTask] = field(default_factory=list)
    failed_uploads: List[UploadTask] = field(default_factory=list)
